package com.ellricky.market.ui

import com.andr.common.http.callback.BaseCallback
import com.andr.common.ui.adapter.BaseRecyclerAdapter
import com.andr.common.ui.mvp.BasePresenter
import com.ellricky.baselib.http.callback.EListCallback
import com.ellricky.baselib.ui.base.BaseRefreshActivity
import com.ellricky.market.*

class IntegralDetailActivity : BaseRefreshActivity<Void, BasePresenter<Void>, MarketIntegralEntity>() {

    override fun initUIView() {
        super.initUIView()
        mTvTitle.text = getString(R.string.market_integral_detail)
    }

    override fun getResponseCallback(): BaseCallback {
        return object : EListCallback<MarketIntegralEntity>(this) {
            override fun onSuccess(data: MutableList<MarketIntegralEntity>?, msg: String?) {
                dataSource = data
                rvView.onLoadFinish(dataSource, refresh)
            }
//            override fun onSuccess(data: MarketIntegralRootEntity, msg: String?) {
//                data.data?.let {
//                    dataSource = it
//                } ?: let {
//                    dataSource = arrayListOf()
//                }
//
//            }

            override fun onErrorCode( code: String?, msg: String?) {
                super.onErrorCode(code, msg)
                rvView.onRefreshFailed(refresh)
            }

            override fun onHttpError(code: String?, msg: String?) {
                super.onHttpError(code, msg)
                rvView.onRefreshFailed(refresh)
            }
        }
    }

    override fun getRvAdapter(): BaseRecyclerAdapter<MarketIntegralEntity> {
        adapter = MarketIntegralAdapter()
        return adapter
    }

    override fun getUrlPath(): String {
       return API_MARKET_INTEGRAL_LIST
    }



}
